package com.loong.shop.controller.forehead;

import com.loong.common.mvc.BaseForeheadController;
import com.loong.common.param.BaseIdParam;
import com.loong.common.rest.Result;
import com.loong.common.validator.group.CommonValidate;
import com.loong.shop.handler.GoodsCategoryHandler;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: 处理前台商品类别请求的Controller
 * @Author: 刘群
 * @Date: 2020/10/27 8:55
 */
@RestController
@RequestMapping("forehead/shop/goodsCategory")
public class GoodsCategoryForeheadController extends BaseForeheadController {

    @Resource
    private GoodsCategoryHandler categoryHandler;

    /**
     * 根据店铺id查询商品分类
     * @param param 店铺id
     * @return 响应的结果
     */
    @PostMapping("findByShopId")
    public Result findGoodsCategoryByShopId(@RequestBody @Validated({CommonValidate.class})BaseIdParam param){
        return handlerExecutor.execute(() -> categoryHandler.foreheadFindGoodsCategoryByShopId(param.getId()));
    }
}
